1 IDENTIFICATION DIVISION
 
   2 PROGRAM-ID HarmonicOscillator
 
   4 COMMENT A mass m is subject to a force F=-k*r.
 
   5 COMMENT What is the trajectory if the mass starts at position (a,0,0)?
 
   6 COMMENT How much time does it take to pass through zero?
 
   7 COMMENT What is the trajectory if it starts at (a,0,0) with velocity (0,v0,0)?
 
   9 COMMENT m*y'' = -k*y (z can be set to 0).
 
  14 REQUIRES COEFFICIENT 4, INTEGRATOR 4, INVERTER 2
 
  19 COEFFICIENT.1 A     # (a,0,0)
 
  20 COEFFICIENT.2 K/M_x # k/m for x
 
  21 COEFFICIENT.3 V0    # (0,v0,0)
 
  22 COEFFICIENT.4 K/M_y # k/m for y, identical to k/m for x
 
  25 -1 -> COEFFICIENT.A -> -a # has to be negative because x' is negative
 
  26 +1 -> COEFFICIENT.V0 -> v0 # has to be positive because y'' is positive
 
  28 x'' -> INTEGRATOR -> -x'
 
  29 -x', IC:-a -> INTEGRATOR -> x
 
  30 x -> COEFFICIENT.K/M_x -> k/m*x
 
  31 k/m*x -> INVERTER -> -k/m*x = x''
 
  33 y'', IC:v0 -> INTEGRATOR -> -y'
 
  34 -y' -> INTEGRATOR -> y
 
  35 y -> COEFFICIENT.K/M_y -> k/m*y
 
  36 k/m*y -> INVERTER -> -k/m*y = y''